package com.small.nine.wxmp.domain.bean.wx.msg;

import com.small.nine.wxmp.common.constant.WxConstant;
import com.small.nine.wxmp.utils.wx.XmlUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 回复视频消息
 *
 * @author sheng_zs@126.com
 * @date 2021-08-02 17:42
 */
@Data
@EqualsAndHashCode(callSuper = true)
@XStreamAlias("xml")
public class WxVideoMsgBean extends WxOutMsgBaseBean {
    private static final long serialVersionUID = 1L;

    /**
     * Video 视频节点
     */
    @XStreamAlias("Video")
    private VideoBean video;

    @Override
    public String toXml() {
        return XmlUtils.beanToXml(this);
    }

    /**
     * 初始化
     *
     * @param toUser      接收者，openID
     * @param fromUser    发送者
     * @param createTime  时间戳
     * @param mediaId     语音ID
     * @param title       视频消息的标题
     * @param description 视频消息的描述
     * @return {@link WxVideoMsgBean}
     */
    public static WxVideoMsgBean getInstance(String toUser, String fromUser, Long createTime,
                                             String mediaId, String title, String description) {
        WxVideoMsgBean msgBean = new WxVideoMsgBean();
        msgBean.setToUserName(toUser);
        msgBean.setFromUserName(fromUser);
        msgBean.setMsgType(WxConstant.MSG_TYPE_VIDEO);
        msgBean.setCreateTime(createTime);
        msgBean.setVideo(VideoBean.getInstance(mediaId, title, description));
        return msgBean;
    }
}
